package com.cloud.basic.webservice.soapClient.SoapAcess;

import java.io.IOException;
import java.io.InputStream;

/**
 * soap接口采集公用工具(支持soap1.1和soap1.2)
 * @author wangliang
 *
 */
public interface CommonAccess {
	public final static String XML_TOP="<?xml version='1.0' encoding='utf-8'?>";
	public final static String SOAP_TOP="<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>";
	public final static String SOAP_HEADER1="<soap:Header>";
	public final static String SOAP_HEADER2="</soap:Header>";
	public final static String SOAP_BODY1="<soap:Body>";
	public final static String SOAP_BODY2="</soap:Body>";
	public final static String SOAP_END="</soap:Envelope>";
	public final static String SOAP_CONTEXT_TYPE="text/xml; charset=utf-8";
	public static final String SOAP12_TOP="<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>";
	public static final String SOAP12_HEADER1="<soap12:Header>";
	public static final String SOAP12_HEADER2="</soap12:Header>";
	public static final String SOAP12_BODY1="<soap12:Body>";
	public static final String SOAP12_BODY2="</soap12:Body>";
	public static final String SOAP12_END="</soap12:Envelope>";
	public static final String SOAP12_CONTEXT_TYPE="application/soap+xml; charset=utf-8";
	public final static String CRED_START="<CredentialSoapHeader>";
	public final static String CRED_END="</CredentialSoapHeader>";
	public final static String STAG="<";
	public final static String ETAG=">";
	public final static String ENDTAG="</";
	public final static String XMLNS=" xmlns=";
	public final static String QUOTE="'";
	public final static String CREDENTIAL="CredentialSoapHeader";
	public final static String CONTENT_LEN="Content-Length";
	public final static String CONTENT_TYPE="Content-Type";
	public final static String SOAPACTION="soapActionString";
	public static final String UTF8="utf-8";
	public static final String POST="POST";
	public final static String ERR_MSG="IO错误";


	/**
	 * 公共接口调用
	 * @param xml
	 * @param urlString
	 * @param soapAction
	 * @param contextType
	 * @return
	 * @throws IOException
	 */
	public String commonAccess(String xml,String urlString,String soapAction,String contextType)throws IOException;

	/**
	 * 公共接口调用
	 * @param xml
	 * @param urlString
	 * @param soapAction
	 * @param contextType
	 * @return
	 * @throws IOException
	 */
	public String commonAccess(byte[] xml,String urlString,String soapAction,String contextType)throws IOException;

	/**
	 * 接口调用底层实现
	 * @param xml
	 * @param xmlLength
	 * @param urlString
	 * @param soapAction
	 * @param contextType
	 * @param reqMethod
	 * @param useCache
	 * @param timeout
	 * @return
	 * @throws IOException
	 */
	public byte[] invoke(byte[] xml,String xmlLength,String urlString,String soapAction,String contextType,String reqMethod,boolean useCache,int timeout) throws IOException;

	/**
	 * 收取流
	 * @param inStream
	 * @return
	 * @throws IOException
	 */
	public byte[] readInputStream(InputStream inStream) throws IOException;

	/**
	 * 收取流
	 * @param inStream
	 * @param charset
	 * @return
	 */
	public String readInputStream(InputStream inStream,String charset);
}
